<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateMapTownshipPlanAreaTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('map_township_plan_area', function (Blueprint $table) {
            $table->id();
            $table->string('wgNumber', 12)->default('')->comment('网规编号');
            $table->unsignedInteger('status')->default(0)->comment('状态');
            $table->unsignedInteger('shopNum')->default(0)->comment('已入驻门店数量');
            $table->string('province', 32)->default('')->comment('省份');
            $table->string('city', 32)->default('')->comment('城市');
            $table->string('district', 32)->default('')->comment('区县');
            $table->string('area', 64)->default('')->comment('区域');
            $table->unsignedInteger('peopleCount')->default(0)->comment('户籍人口数');
            $table->unsignedInteger('landArea')->default(0)->comment('土地面积');
            $table->string('address')->default('')->comment('地址');
            $table->unsignedInteger('fiftyUpAreaCount')->default(0)->comment('营业面积50平方米以上的综合商店或超市个数');
            $table->float('lat', 10,7)->default(0)->comment('纬度');
            $table->float('lng', 10,7)->default(0)->comment('经度');
            $table->float('peopleDensity', 9,6)->default(0)->comment('人口密度');
            $table->unsignedInteger('peopleDensityRank')->default(0)->comment('人口密度排名');
            $table->unsignedInteger('shopCountRank')->default(0)->comment('商超数排名');
            $table->unsignedInteger('totalWeight')->default(0)->comment('综合权重');
            $table->unsignedInteger('totalRank')->default(0)->comment('综合排名');
            $table->float('median', 7, 4)->default(0)->comment('中位数');
            $table->float('lowerQuartile', 8, 5)->default(0)->comment('下四分位数');
            $table->float('upperQuartile', 8, 5)->default(0)->comment('上四分位数');
            $table->unsignedInteger('grade')->default(0)->comment('乡镇分级');
            $table->string('townNameGrade', 12)->default('')->comment('镇名称等级');
            $table->unsignedInteger('qianqiangTownRank')->default(0)->comment('千强镇排名');
            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');
            $table->collation = 'utf8mb4_general_ci';
            $table->index('grade', 'idx_grade');
            $table->index('wgNumber', 'idx_wgNumber');
            $table->comment = '乡镇规划地区';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('map_township_plan_area');
    }
}
